import React from "react";
import { Option } from "../../MultiCheck";
export interface CheckboxProps {
  checked?: boolean;
  name?: string;
  value: string;
  onChange?: (option: Option) => void;
  className?: string;
}

const InternalCheckbox: React.FunctionComponent<CheckboxProps> = ({
  onChange,
  name,
  value,
  checked,
}): JSX.Element => {
  const onInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
    onChange?.({
      value,
      checked: e.target.checked,
      label: value,
    });
  };
  return (
    <label className={"Checkbox"}>
      <input onChange={onInputChange} checked={checked} type="checkbox" />
      {name}
    </label>
  );
};

export default InternalCheckbox;
